import BaseItemView from "../../../cfw/mvc/BaseItemView";
import BathItemModel from "../model/BathItemModel";
import { ItemState } from "../../../cfw/tools/Define";
import BaseItemModel from "../../../cfw/mvc/BaseItemModel";

const { ccclass, property } = cc._decorator;

@ccclass
export default class BathItemView extends BaseItemView {


    @property(cc.Sprite)
    ad: cc.Sprite = null;

    protected model: BathItemModel;
    start() {
        super.start();
        this.updateState();
    }


    addListener() {
        this.eventProxy.on(BaseItemModel.UPDATE_STATE, this.updateState, this)
    }

    onDestroy() {
        super.onDestroy()
    }

    getOpenLevel() {
        return this.model.getOpenLevel()
    }

    isOpen() {
        return this.model.isOpen()
    }

    updateState() {
        // this.model.setState(state)
        if (!this.model.needBuy()) {
            if (this.ad) {
                this.ad.node.active = false;
            }
        }
    }

    needBuy() {
        return this.model.needBuy()
    }

}
